package cn.hs.service.impl;/**
 * @author Jovan Hou 2024/10/22
 **/

import cn.hs.entity.Article;
import cn.hs.entity.Fm;
import cn.hs.mapper.FmMapper;
import cn.hs.service.FmService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName FmServiceImpl
 * @Description TODO
 * @Author CnYuu
 * @Date 2024年10月22日 20:49
 * @Version 1.0
 */

@Service
public class FmServiceImpl implements FmService
{
    @Autowired
    private FmMapper fmMapper;
    @Override
    public int insert(Fm fm)
    {

        return fmMapper.insert(fm);
    }

    @Override
    public int deleteById(Integer id)
    {
        return fmMapper.deleteByPrimaryKey(Long.valueOf(id));
    }

    @Override
    public int update(Fm fm)
    {
        return fmMapper.updateByPrimaryKey(fm);
    }

    @Override
    public PageInfo findAll(Integer pageNum, Integer pageSize, Fm fm)
    {
        PageHelper.startPage(pageNum, pageSize);
        List<Fm> fms = fmMapper.selectAll(fm);
        PageInfo<Fm> pageInfo = new PageInfo<>(fms);
        return pageInfo;
    }

    @Override
    public Fm selectById(Integer id)
    {
        return fmMapper.selectByPrimaryKey(Long.valueOf(id));
    }


}
